var utils = require("../../utils/utils");
var ocrGml = require("../../utils/ocrGml");
var ACTION = require("../../base/action");
var common = require("./common");
var baoShuangAd = require("../appCommon/baoShuangAd");
const appUtils = require("../../utils/app");

var aTreasure = new ACTION("开宝箱", {
  storgae: common.storage,
});

aTreasure.exec = function () {
  var content = "开宝箱得红包";
  var UIText = utils.existsTextStartsWith(content);
  if (UIText) {
    utils.clickUIText(UIText);
    sleep(utils.getRandom(1.5, 2, 1000));
    var content = "立即领取";
    var UIText = utils.existsTextStartsWith(content);
    utils.clickUIText(UIText);
    sleep(utils.getRandom(1.5, 2, 1000));
    baoShuangAd.ad.watchAd();
    var content = "开心收下";
    var UIText = utils.existsTextStartsWith(content);
    if (UIText) {
      utils.clickUIText(UIText);
      sleep(utils.getRandom(1.5, 2, 1000));
    }
  } else {
    console.log("没找到", "开宝箱得红包");
  }
};

module.exports = aTreasure;
